home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / MUBBS etc.cpt / Module Source / Example1 Module code / Some Tests.c < prev   
Text File  |  1991-11-19  |  4KB  |  106 lines

  1. /*
  2.  *  Some Tests.c
  3.  *
  4.  *    This program source code and it's compiled version is
  5.  *  Copyright (c) 1991 N. Hawthorn.
  6.  *  This program source code and it's compiled version IS NOT IN THE
  7.  *  PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
  8.  *  regarding use of this program source code and it's compiled version.
  9.  *
  10.  *
  11.  *  Some examples for you...
  12.  *
  13.  */
  14.  
  15. #include "MUBBS Module.h"
  16.  
  17. struct PPP {            /* this struct is NOT created here (globally) ! */
  18.             int hahaha; /* this is a test struct to pass some variables to the other */
  19.             int hehe;   /* test module */
  20.             };          /* you DONT HAVE TO USE THIS, just pass 0 to the module in P */
  21.                            /* and make this a empty struct */
  22.  
  23. tests(){
  24.  
  25. char datetime[25], testchars[26];
  26.  
  27. struct PPP P;    /* create the struct here (on the stack) */
  28.                 /* we actually MAKE the struct in memory HERE, so that we can */
  29.                 /* pass it's location to the other module !!! */
  30.                 /* both modules need to know the struct's internal values */
  31.  
  32. if (!G->online[u]) goto byebye; /* do this check so we can log out if hang up */
  33. print("C> This is the print() routine, only on the mac screen, module mode is %d.\n",mode[u]);
  34.  
  35. loop:
  36. loguser(G->modulename[u]); /* this tells where you are for remote sysop, or writes to log file */
  37.  
  38. /* you print the following so that the sysop can monitor use on the mac screen */
  39.  
  40. print("C> Line %d %s, at: %s\n",(u+1),G->username[u],G->modulename[u]);
  41.  
  42. /* this print is for the Example module only */
  43.  
  44. print("\nC> This module's name is :%s, the calling module's name was :%s  ",G->modulename[u],G->oldmodulename[u]);
  45. send("]]  *** Example1 Module Menu ***]]");
  46. if (!(cmd1(">> Cmd1, In, Getdatetime, Module, Xmodule, Portsin, Sendtext, Wait, Quit :"))) goto byebye; /* timeout */
  47. send (G->CR[u]);
  48. switch (G->input[u]) {
  49.     case 'C':
  50.         if (!(cmd1("]Now waiting for one character :"))) goto byebye; /* timeout */
  51.         send("]The character I got was \"%c\".]",G->input[u]);
  52.         break;
  53.     case 'G':
  54.         getdatetime(datetime); /* gets the date & time */
  55.         send("]You are on line %d at %s PST]", (u+1), datetime);
  56.         break;
  57.     case 'I':
  58.         send("]Using in() to get a character, input it here :");
  59.         if (!G->in()) goto byebye; /* timeout */
  60.         send("]The character I got was \"%c\".]",G->input[u]);
  61.         break;
  62.     case 'M':
  63.         P.hahaha=25;
  64.         P.hehe=56;
  65.         send("]P.hahaha=%d, P.hehe=%d before the call",P.hahaha,P.hehe);
  66.         send("]Now calling another module from this one..]");
  67.         module (3,"example2",&P); /* int mode & module's name & pointer to the joe struct */
  68.         send("]P.hahaha=%d, P.hehe=%d AFTER the call",P.hahaha,P.hehe);
  69.         break;
  70.     case 'X':
  71.         send("]Now calling another module from this one, 0 in the pointer !]");
  72.         module (2,"example2",0L); /* int mode & module's name & a empty pointer (long) */
  73.         break;
  74.     case 'P':
  75.         send("]You can type in up to 24 chars here :");
  76.         portsin(testchars, 24);
  77.         if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  78.                                          /* always check for online before continuing */
  79.         send("]You typed in: \"%s\" ",testchars);
  80.         send(G->CR[u]);
  81.         break;
  82.     case 'S':
  83.         send("]sending \":testtext:test.txt\"]");
  84.         G->okcancel[u]=TRUE;
  85.         G->nocheck[u]=FALSE; /* check for controls */
  86.         G->cancel[u]=FALSE;
  87.         sendtext(":testtext:test.txt"); /* send this file in this folder */
  88.         break;
  89.     case 'W':
  90.         send("]Going to wait for 20 seconds, all other ports will not stop though!]");
  91.         wait(20);
  92.         break;
  93.     case 'Q':        /* Quit */
  94.         return;
  95.         break;
  96.     }
  97. if (!G->online[u]) goto byebye; /* log out */
  98. goto loop;
  99.  
  100. byebye:
  101. G->online[u]=FALSE; /* show we timed out */
  102. }
  103.  
  104.  
  105.  
  106.